CUBE CONNECT Edition Help

Examples and FAQ

This section contains examples for using the Highway program, along with a link to Frequently Asked Questions.

Example 1: Simple Equilibrium Assignment

This example shows a simple equilibrium assignment procedure assuming a typical input highway network providing CAPACITY, DISTANCE AND SPEED on the link attributes.

RUN PGM=HIGHWAY
FILEI NETI = Network.net
FILEI MATI[1] = TRIPS.mat
FILEO NETO = LOADED.NET
PARAMETERS COMBINE=EQUI MAXITERS = 99 GAP=.0001
PROCESS PHASE = LINKREAD

   C = LI.CAPACITY ; set capacity equal to a link field
; assumes DISTANCE and SPEED are available on the input network
; no LINKCLASS defined, therefore defaults to 1 for all links
ENDPROCESS
PROCESS PHASE=ILOOP     ; main loop for program
   PATHLOAD PATH=TIME,  ; build path based on time
      VOL[1]=MI.1.CAR   ; load trips from input matrix to volume set 1
ENDPROCESS
; No TC functions defined therefore congested travel times computed using
; the standard BPR formula for all links.
; No COST function defined therefore COST defaults to TIME
ENDRUN

Example 2: Level-of-Service Skimming

This is a simple example of using HIGHWAY to "SKIM" level of service information from the loaded highway network from Example 1. This example builds paths on the congested travel time variable in the loaded network and "Skims", or extracts, the zone- to-zone times and distances for those paths to an external matrix file.

RUN PGM=HIGHWAY
FILEI NETI = LOADED.NET
FILEO MATO[1] = HWY_SKIMS.MAT,
MO=1-2,NAME= 'HWY Time', ‘HWY Distance’
PROCESS PHASE=LINKREAD
T0=li.TIME_1 ; Final congested travel times on the input network ENDPROCESS
PROCESS PHASE=ILOOP
; Loop across all origin zones and build path using congested time.
; skim TIME and DISTANCE for the min TIME paths into work matrices 1 and 2
   PATHLOAD PATH=TIME, MW[1]=PATHTRACE(TIME), MW[2]=PATHTRACE(LI.DISTANCE)
; For intrazonals, make the intrazonal time equal to half the time to the nearest zone
   COMP MW[1][I] = rowmin(1) * 0.5 ; Intrazonal time
; Set the intrazonal distance equal to 0
   COMP MW[2][I] = 0
ENDPROCESS
ENDRUN

Example 3: Junction-Constrained Equilibrium Assignment

This example script runs a junction constrained equilibrium assignment dumping the path file, final turn delays and the binary junction data file.

RUN PGM=HIGHWAY
FILEI NETI = NETWORK.NET
FILEI MATI[1] = VEHICLETRIPS.MAT
FILEI JUNCTIONI = JUNC_BASE.IND,
   period=60,set=1
FILEO NETO = LOADED.NET
FILEO PATHO[1] = ROADPATHS.PTH
FILEO TURNPENO = TURNDELAYS.DAT
FILEO JUNCTIONO = TURNS.INT
; set convergence method and criteria
PARAMETERS COMBINE = EQUI, GAP = 0.005, maxiters=99
PARAMETERS EQUITURNCOSTFAC=1
; ----- SET CAPACITY and group links
PROCESS PHASE=LINKREAD
   C = LI.CAP
   IF (LI.FUNC_CLASS = 1-2) LINKCLASS=1
   IF (LI.FUNC_CLASS = 3-10) LINKCLASS=2
ENDPROCESS
PROCESS PHASE=ILOOP
   PATHLOAD PATH = TIME, VOL[1]=MI.1.1,
            PATHO=1, NAME='assignment',ALLJ=T,
            INCLUDECOSTS=T,PENI=1
ENDPROCESS
PROCESS PHASE=ADJUST
function {
   tc[1]=t0*(1.0+0.15*((v/c)^8))
         ; congested time function for major roads
   tc[2]=t0*(1.0+0.15*((v/c)^4))
         ; congested time function for minor roads
ENDPROCESS
ENDRUN

Example 4: Subarea Assignment and Extraction

This script shows an example of both subarea assignment and subarea matrix extraction for multiple trip purposes. The subarea network is created with CUBE/VIPER POLYGON tools with the default renumbering of the network.

RUN PGM=HIGHWAY
NETI=DEMO.NET
; subarea network created with POLYGON tools in CUBE/VIPER
FILEI SUBAREANETI=subarea1.net
MATI=TRIPSBYPURPOSE.MAT
FILEO NETO=Loaded_DEMO.NET
FILEO SUBAREAMATO=submat1.mat NAME=HTW,WTH,HTO,OTH,NHB,TOTAL
PARAMETERS COMBINE=EQUI GAP=.0001
PHASE=LINKREAD
   LINKCLASS=LI.CLASS
   C=LI.CAPACITY
ENDPHASE
PHASE=ILOOP
; this PATHLOAD statement builds paths on TIME, assigns each trip purpose
; and the total trips to separate volume sets,
; extracts a subarea matrix for each trip purpose and the total trips
PATHLOAD
PATH=TIME,VOL[1]=mi.1.1,,VOL[2]=mi.1.2,VOL[3]=mi.1.3,VOL[4]=mi.1.4,
            VOL[5]=mi.1.5,VOL[6]=mi.1.6,
            SUBAREAMAT[1]=mi.1.1,SUBAREAMAT[2]=mi.1.2,
            SUBAREAMAT[3]=mi.1.3,SUBAREAMAT[4]=mi.1.4,
            SUBAREAMAT[5]=mi.1.5,SUBAREAMAT[6]=mi.1.6
ENDPHASE
PHASE=ADJUST
; volume function V sets the volume to use for V/C in the delay function
; No delay functions (TC[#]=) are specified here so the default BPR
; formula is used for all link classes
FUNCTION V=VOL[6] ; set volume to use in congested travel time functions
ENDPHASE
ENDRUN

Example 5: Select-Link Assignment

This script has two steps. In step 1 several examples of select link assignment are shown. In step 2, a MATRIX job is run to build trip end reports for the select link trip matrices created in step 1.

; Step 1 Select Link Assignment
RUN PGM=HIGHWAY
MATI=TRIPS.MAT
NETI=DEMO.NET
NETO=DEMOSelectLink.NET
MATO = MATVOUT.MAT,mo=1-2,4 dec=2, combine=Y
; this is an example of an incremental assignment procedure
; the number of fractions defines the number of iterations
; at each iteration the listed fraction of the trip table is assigned COMBINE=SUM,FRACTIONS=0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.05,0.05,0.05,0.05,0.0 5,0.05
; Equilibrium assignment could be performed specifying COMBINE=EQUI
; or volume averaging by specifying COMBINE=AVE if desired
PHASE=LINKREAD
LINKCLASS=LI.CLASS
C=LI.CAPACITY ENDPHASE
PHASE=ILOOP
PATH=TIME,VOL[1]=mi.1.6, mw[1] = mi.1.6, selectlink = (L=1449-1495), vol[2] = mw[1]
mw[2]=mi.1.6
/* this step says "build paths based on time, assign trips from mi.1.6 to these paths and put them in Volume set 1 (V1_1 on the output network), put trips from mi.1.6 into working matrix 1 if they are on paths that use the selected links (L=), assign the trips in working matrix 1 (the select link trips) back to the time based paths and put them into Volume set 2 (V2_1 on the output network), and lastly put the total trips assigned from mi.1.6 into working matrix 2. Note that on the MATO line mo=1-2 will output the selected trip matrix (1) and the total trip matrix assigned (2) */
   PATH=TIME,VOL[3]=mi.1.6, mw[4] = mi.1.6, selectlink = (L=1494-1423), vol[4]=mw[4]
/* this step says "build paths based on time, assign trips from mi.1.6 to these paths and put them in Volume set 3 (V3_1 on the output network), put trips from mi.1.6 into working matrix 4 if they are on paths that use the selected links (L=), assign the trips in working matrix 4 (the select link trips) back to the time based paths and put them into Volume set 4 (V4_1 on the output network). Note that on the MATO line mo=4 will output the selected trip matrix (4) for the links L=. Now you have 4 volume sets, but only want to calculate congested travel times based on the true total volumes on each link. This is why you need the function V=vol[1]. Note that V=vol[3] would give the same result as these two sets are the same.
The V function is automatically executed during the adjust phase. */

ENDPHASE
PHASE=ADJUST
function { V=vol[1] }

/* this function sets the volume for the capacity restraint to be the total volume. Without this statement, V is set to the sum of all volume sets which double counts volume when you have a select link volume set */

ENDPHASE
ENDRUN

; Step 2 Extract and report select link trip ends
RUN PGM=MATRIX
; note this example was for a 25 zone network
FILEI MATI=matvout.mat
mw[1]=mi.1.1
array sum_mat = 25
array row_tot = 25
row_TOT[I] = rowsum(1)
Jloop
sum_mat[J] = sum_mat[J] + mw[1][J]
endjloop
IF (I=25)
   LOOP INDEX=1,25
      PRINT FORM=10.0, LIST=INDEX,ROW_TOT[INDEX],SUM_MAT[INDEX],
         file =SelectTripEnds.txt
   ENDLOOP
ENDIF
ENDRUN

Example 6: Toll Gate accumulation using LINKIDARRAY

This script is an example of using LINKIDARRAY to accumulate information about toll gate use from the paths into working matrices. In this example, the LINKIDARRAY uses li.TOLL. This network data field contains a value of 1-8 corresponding to one of the eight toll bridges in the San Francisco Bay Area network. The output work matrices include: #1 is the travel time on the I-J path, #2 is the number of toll gates traversed on the path, #3 is the number of the last toll gate traversed on the path and #4-#8, include the 1st, 2nd, 3rd and 4th gate number traversed on the path if used.

RUN PGM=HIGHWAY
FILEI NETI = SF_BAY_AREA.NET
FILEO MATO[1] = test.mat,
mo=1-8
PHASE=LINKREAD
LW.TIM=LI.DISTANCE/LI.FFS * 60
If (li.USE=2,3) ADDTOGROUP=1 ; don't use HOV facilities,
; they by pass tolls
ENDPHASE
PHASE=ILOOP
PATHLOAD PATH = LW.TIM, EXCLUDEGROUP=1,
MW[1] = PATHTRACE(LW.TIM), LINKIDARRAY=li.TOLL,
LINKIDCNTMW=2 LINKIDLASTUSE=3 LINKIDMW=4-8
ENDPHASE
ENDRUN
Exampl

Example 7: Using TOLLMATI to incorporate closed system Tolls in the Pathbuilding process

This example uses TOLLMATI to incorporate closed system tolls into the pathbuilding process. In this example, the paths are built on COST and the COST function will include any gate to gate tolls traversed on a path.

RUN PGM=HIGHWAY
FILEI TOLLMATI[1] = "TOLL.DBF",
   ENTRYGATE=ON_RAMP, EXITGATE=OFF_RAMP, TOLLS=COST_CAR,COST_TRUCK,
   NETIENTRY=ONRAMP, NETIEXIT=OFFRAMP, NETITOLLROAD=TOLLROAD
FILEI NETI = "BASE.NET"
FILEI TURNPENI = "PROHIBIT1.PEN"
FILEI MATI[1] = "PKHOURTRIPS.MAT"
FILEO TURNVOLO[1] = "TURNS.DBF",
   FORMAT=DBF
FILEO NETO = "TOLLLOAD.NET"
FILEO PATHO[1] = "TOLLPATH.PTH"
FILEO JUNCTIONO = "JUNCTION1.DAT"
FILEO MATO[1] = "TOLLSKIM.MAT",
MO=1-5,99 NAME=PATHCOST,COST,PATHTOLL,TIME,VEHTOLLS,LOADS

PAR MAXITERS=20
TURNS N=1-9999
PROCESS PHASE=LINKREAD

C = LI.CAP
IF (LI.FUNC_CLASS = 1-2)
   LW.COEF=0.15
   LW.EXPO=8.00
ELSE
   LW.COEF=0.15
   LW.EXPO=4.00
ENDIF

ENDPROCESS

PROCESS PHASE=ILOOP
; -----------------------------------------------------------
; trips to load
   MW[99]=MI.1.1+MI.1.2
; -----------------------------------------------------------
; Assign WITH TOLL COST CONSIDERED
  PATHLOAD PATH=COST, VOL[1]=MW[99],
                      PENI=1  TOLLMATI=1,1,
                      TOLLFACTOR=2.0, ; toll factor is in min/toll units,
                                      ; here 2min/$ (implies VOT=$30/hr)
                      MW[1]=PATHCOST, NOACCESS=0,
                      MW[2]=PATHTRACE(COST,1), NOACCESS=0,
                      MW[3]=PATHTOLL,
                      MW[4]=PATHTRACE(TIME,1),NOACCESS=0,

MW[5]=mw[3]*mw[99] ; cross trips with tolls
ENDPROCESS

PROCESS PHASE=ADJUST
function {
tc=t0*(1.0+LW.COEF*((v/c)^LW.EXPO))
  ; congested time function for major roads
}
ENDPHASE
ENDRUN

Example 8: Multiple User Class Assignment with Cost based on User Class

These examples use generalized cost functions customized for different user classes. Highway will then use the COST of the system to compute Lambda and the convergence measures.

Example 9: Multiple User Class Assignment with Cost based on Link Class

This example shows a multi user class equilibrium assignment, building paths on a generalized cost function with the cost functions differentiated by the facility type (LINKCLASS). Turn penalties are included in the path building process and the PATH file is saved for graphical analysis.

Compared to the previous Example 8: Multiple User Class Assignment with Cost based on User Class, here there is only one PATHLOAD that assigns both VOL[1] and VOL[2] based on PATH=COST. Both user classes are thus assigned based on the same cost function.

RUN PGM=HIGHWAY
FILEI NETI = NETWORK.NET
FILEI MATI[1] = TRIPS.MAT
FILEI TURNPENI = TURNPEN.PEN
FILEO NETO = LOADED.NET
FILEO PATHO[1] = HWY_PATHS.PTH
; set parameters and values for time and distance costs
PARAMETERS COMBINE = EQUI GAP = 0.005
   time_cost1 = 0.5
   time_cost2 = 0.7
   distance_cost1 = 0.2
   distance_cost2 = 0.4
; ----- SET CAPACITY and LINKCLASS
PROCESS PHASE=LINKREAD
   CAPACITY = LI.CAPACITY * 1.0
; set link classes for major roads
   IF (li.CLASS = 1-4) LINKCLASS = 1
; set link classes for minor roads
   IF (li.CLASS = 5-10) LINKCLASS = 2
; group railway links for exclusion from assignment
   IF (li.CLASS = 11 | li.CLASS = 12) ADDTOGROUP=1
ENDPROCESS
PROCESS PHASE=ILOOP
PATHLOAD PATH=COST,
   PENI=1-2,            ; include turn penalties,
   VOL[1]=MI.1.CAR,     ; load car trips,
   VOL[2]=MI.1.TRUCKS,  ; load truck trips,
   EXCLUDEGROUP=1,      ; exclude rail links
   PATHO=1 NAME=COST_PATH INCLUDECOSTS=T ALLJ=T
                        ; save path file ENDPROCESS
PROCESS PHASE=ADJUST
; Define cost and delay functions
function {
   tc[1]=t0*(1.0+0.15*((v/c)^8))
                        ; congested time function for major roads
   tc[2]=t0*(1.0+0.15*((v/c)^4))
                        ; congested time function for minor roads
   cost[1]=time*time_cost1+li.distance*distance_cost1
                        ; cost function for major roads
   cost[2]=time*time_cost2+li.distance*distance_cost2}
                        ; cost function for minor roads
ENDPROCESS
ENDRUN

Example 10: Shortest Path Trees Using TREEO

The FILEO TREEO and PATHLOAD TREEO can be used to output shortest path trees. Below is a sample script, descriptions of the outputs and step-by-step guide on how to read the output file.

RUN PGM=HIGHWAY
NETI=Highway.net
TREEO[1]="PathTree.txt",
   FORMAT=TXT,
   ROWTYPE=0,
   CELLTYPE=1,
   FORM=10, 6, 6,
   ORIGINTYPE=0,
   LISTNETNODE=T,
   LISTCOLNUMS=T,
   LISTLINKS=T,
   LISTALTNODES=T,
   ALTNODEFIELD=EMNODENUM
PHASE=ILOOP
PATH=LI.T0,
   TREEO=1, NAME='Free Flow'
ENDPHASE

ENDRUN

Output Description 1: ROWTYPE, LISTCOLNUMS, LISTLINKS, LISTNETNODE, CELLTYPE

Output Description 2: FORM

Output Description 3: ORIGINTYPE, LISTALTNODES, ALTNODEFIELD

How to read a TREEO file?

To build a path from zone 4 to node 19, we follow the steps below:

Step 1: Go to the row for origin zone 4 (row #4) and column for node 19 (column #10). Get the cell value. This value (in this case node 16) is the first node from the destination 19 (16 -> 19).

Step 2: Go to the row for origin zone 4 (row #4) and column for node 16 (column #7). Get the cell value (in this case 15). The path tree further advances as 15 -> 16 -> 19.

Step 3: Go to the row for origin zone 4 (row #4) and column for node 15 (column #6) . Get the cell value (in this case 18). The path tree further advances as 18 -> 15 -> 16 -> 19

Step 4: Go to the row for origin zone 4 (row #4) and column for node 18 (column #9) . Get the cell value (in this case 4). The path tree further advances as 4 -> 18 -> 15 -> 16 -> 19

This completes the minimum cost path for origin zone to destination 19.

ROWTYPE= 0: Number of cells in each row is the number of nodes in the network

CELLTYPE= 1: The cell values are set to the highway node numbers

Example 11: Using TOLLMATI and TOLLVOLO

RUN PGM=HIGHWAY
FILEI NETI=Toll.net
FILEO NETO=Tollload.net
FILEI MATI[1]=Trips.mat
FILEI TOLLMATI[1]=TollCost.dbf,ENTRYGATE=TollOn,EXITGATE=TollO ff,TOLLS=Toll1,Toll2,
NETIENTRY=tollentry,NETIEXIT=tollexit,NETITOLLROAD=tollr oad
FILEI TOLLMATI[2]=TollCost2.dbf,ENTRYGATE=TollOn,EXITGATE=Toll Off,TOLLS=Toll1,Toll2,
NETIENTRY=tollentry,NETIEXIT=tollexit,NETITOLLROAD=tollr oad
FILEI TOLLMATI[4]=TollCost4.dbf,ENTRYGATE=TollOn,EXITGATE=Toll Off,TOLLS=Toll1,Toll2,
NETIENTRY=tollentry,NETIEXIT=tollexit,NETITOLLROAD=tollr oad
FILEO tollvolo[1]=tolltrip.dbf, FORMAT=dbf,DEC=3, INCLUDE0=f
FILEO tollvolo[2]=dtowntest.mdb\tolltrip2,FORMAT=dbf,DEC[1]=d, INCLUDE0=f,
NAMES=OnGate,OffGate,-,-,-,- ,MiNum,TSet,VSet,PSet,TollTrip
FILEO TOLLVOLO[3]=tolltrip.txt, FORMAT=txt,dec=1, INCLUDE0=f,ONGATES=1-2
FILEO TOLLVOLO[4]=tolltrip2.txt,FORMAT=txt,dec=2, INCLUDE0=f,OFFGATES=3-6,
NAMES=OnGate,OffGate,-,-,-,- ,MiNum,TSet,VSet,PSet,TollTrip
FILEO TOLLVOLO[5]=tolltrip.csv, FORMAT=txt,dec=3, INCLUDE0=f,DELIMITER=',',TOLLMATI=2-4
FILEO TOLLVOLO[6]=tolltrip2.csv,FORMAT=txt,DEC=4, INCLUDE0=f,DELIMITER=',',TOLLMATI=2-4,
NAMES=OnGate,OffGate,-,-,-,- ,MiNum,TSet,VSet,PSet,TollTrip

FILEOTOLLVOLO[7]=tolltrip.mat,FORMAT=mat,DEC=s,d,3*4, MO=M?T?V?P?
FILEO TOLLVOLO[8]=tolltrip2.mat,FORMAT=mat,DEC=s,d,3*4,PATHSET S=11,21,41,42,
TOLLSETS=2,MO=M1T1P12V3,M1T1P11V1,M4T1P?V?,M?T?V?P?
PHASE=ILOOP
MW[1] = MI.1.1
PATH=time, VOL[1]=MW[1] TOLLMATI=1,1 TOLLPATHSET=11
PATH=time, VOL[2]=MW[1] VOL[3]=MW[1] VOL[4]=MW[1] TOLLMATI=1,2 TOLLPATHSET=12
PATH=time, VOL[3]=MW[1]
PATH=time, VOL[4]=MW[1] TOLLMATI=2,2
PATH=time, VOL[4]=MW[1] TOLLMATI=2 TOLLPATHSET=20
PATH=time, VOL[1]=MW[1] TOLLMATI=4,1 TOLLPATHSET=41
PATH=time, VOL[2]=MW[1] VOL[3]=MW[1] VOL[4]=MW[1] TOLLMATI=4,2 TOLLPATHSET=42
PATH=time, VOL[3]=MW[1]
PATH=time, VOL[4]=MW[1] TOLLMATI=2,1 TOLLPATHSET=21
PATH=time, VOL[4]=MW[1] TOLLMATI=4 TOLLPATHSET=40
ENDPHASE
ENDRUN

Frequently asked questions

Please see FAQ - Highway in Frequently Asked Questions.